package com.javaIO.demo1;

import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;

public class Test3 {
    public static void main(String[] args) {

        FileInputStream inputStream = null;
        FileOutputStream outputStream = null;
        try {
            //1.读取内容
            inputStream = new FileInputStream("D:\\SoftDevelopment\\Java\\file\\demo1.txt");
            //2.写入内容
            outputStream = new FileOutputStream("D:\\SoftDevelopment\\Java\\file\\demo\\demo1.txt");

            int by;
            while ((by = inputStream.read()) != -1) {
                //写入数据
                outputStream.write(by);
            }

        } catch (Exception e) {
            throw new RuntimeException(e);
        }finally {
            try {
                if (inputStream != null) {
                    inputStream.close();
                }
                if (outputStream != null) {
                    outputStream.close();
                }
            } catch (IOException e) {
                System.out.println(e.getMessage());
            }

        }

    }
}


